package com.yzyz.bean;

import java.io.Serializable;
import java.util.Date;
import java.util.Observable;

import com.yzyz.utils.ValidateUtils;

/**
 * 
 * @author David Sun
 * @Date   2010-3-31
 *
 */
public abstract class BaseBean extends Observable implements Serializable {
	
	private static final long serialVersionUID = 8624578321850379605L;
	
	protected int id;
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null){
			return false;
		}
		if(obj instanceof BaseBean){
			BaseBean base = (BaseBean)obj;
			if(base.getId() != this.id){
				return false;
			}
			if(!ValidateUtils.isEquals(base.getName(), this.name)){
				return false;
			}
			if(this.level != base.getLevel()){
				return false;
			}
			return true;
		}
		return false;
	}
	protected String name;
	
	protected boolean available = true;
	
	protected Date date;
	
	protected int level;
	
	/**
	 * 删除标识，如果被删除了，就需要删除缓冲内的相应数据
	 */
	private boolean deleted;
	
	public boolean isDeleted() {
		return deleted;
	}
	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public boolean isAvailable() {
		return available;
	}
	public void setAvailable(boolean available) {
		this.available = available;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public void setChanged(){
		super.setChanged();
	}
	
	
}
